<template>
	<view class="pageAll">
		<view class="pageTop">
			<input type="number" maxlength="6" placeholder-style="color:#b57979;" v-model="form.pwd" placeholder="请输入新的文件确认密码"/>
			<input type="number" maxlength="6" placeholder-style="color:#b57979;" v-model="form.rePwd" placeholder="请确认新的文件确认密码"/>
		</view>
		<view class="bottomBtnView">
			<button class="bottomBtn" @click="submit" hover-class="subActive">
				完&nbsp&nbsp成
			</button>
		</view>
		<logo class="Bottomlogo"></logo>
	</view>
</template>

<script>
	import logo from '../../../components/logo/bottomLogo.vue'
	import { HBValidate } from '../../../utils/tools.js'
	export default {
		data() {
			return {
				form:{
					pwd:null,
					rePwd:null,
				},
				needGoBack: false,
			}
		},
		methods: {
			submit() {
				const validate = new HBValidate()
				if(!validate.isFilePwd(this.form.pwd)) {
					uni.showToast({
						title: '文件确认密码格式错误',
						icon: 'none'
					})
				} else if(this.form.pwd !== this.form.rePwd) {
					uni.showToast({
						title: '两次密码不一致',
						icon: 'none'
					})
				} else {
					this.$api.updateOrderPassword({
						order_password: this.form.pwd,
						order_password_verify: this.form.rePwd,
					}).then(res => {
						if(res.status) {
							uni.showToast({
								title:'修改成功',
								duration:1500,
							})
							setTimeout(() => {
								if(this.needGoBack) {
									uni.navigateBack({
										delta:2,
									})
								} else {
									uni.switchTab({
										url:"../message/message"
									})
								}
								
							}, 1500)
						} else {
							uni.showToast({
								title:res.msg,
								icon:'none',
							})
						}
					})
				}
			}
		},
		onLoad(option) {
			if(option.back) {
				this.needGoBack = true
			}
		},
		components: {
			logo,
		},
		onShareAppMessage: (options) => {
			// 设置菜单中的转发按钮触发转发事件时的转发内容
			var shareObj = {
				title: "红标HONBIAO", // 默认是小程序的名称(可以写slogan等)
				path: '/pages/indexPage/authorization/authorization', // 默认是当前页面，必须是以‘/’开头的完整路径
				imageUrl: '/static/index/labelRouge.png', //自定义图片路径，可以是本地文件路径、代码包文件路径或者网络图片路径，支持PNG及JPG，不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
				success: (res) => {
					// 转发成功之后的回调
					if (res.errMsg == 'shareAppMessage:ok') {}
				},
				fail: () => {
					// 转发失败之后的回调
					if (res.errMsg == 'shareAppMessage:fail cancel') {
						// 用户取消转发
					} else if (res.errMsg == 'shareAppMessage:fail') {
						// 转发失败，其中 detail message 为详细失败信息
					}
				}
			};
			return shareObj
		},
	}
</script>

<style scoped>
	.pageAll{
		box-sizing: border-box;
		background-color: #fdf5f3;
		width: 100%;
		height: 100%;
		padding: 17upx;
		display: inline-block;
	}
	.pageTop{
		
	}
	.pageTop input{
		height:100upx;
		border-radius: 10upx;
		background-color: #FFF;
		box-shadow: 0 0 30upx -15upx #f03d3d;
		margin-bottom: 15upx;
		font-size: 32upx;
		color:#b57979;
		padding: 0 15upx;
	}
	.bottomBtnView{
		margin-top: 200upx;
	}
	.bottomBtn{
		color:#FFF;
		font-size: 36upx;
		background-color: #f7533e;
		font-weight: 200;
	}
	.bottomBtn:after{
		border:none;
	}
	.subActive{
		background-color: #FF0000 !important;
	}
</style>
